home *** CD-ROM | disk | FTP | other *** search
- Path: news.lpr.carel.fi!usenet
- From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
- Newsgroups: comp.lang.c
- Subject: Re: Split Filename
- Date: Thu, 25 Jan 1996 12:47:16 +0200
- Organization: Carelcomp Forest
- Message-ID: <31075FB4.3E53@cmt.lpr.mail.carel.fi>
- References: <4e6lsr$8ar@news1.radix.net>
- NNTP-Posting-Host: renoir.cclahti.carel.fi
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (WinNT; I)
-
- Jim Ward wrote:
- >
- > Is there a C function that will split
- > /home/file.c into /home and file.c ?
- >
- > Thanks,
- >
- > Jim Ward
-
- You could try:
-
- char pathandfile[] = "/home/file.c";
- char *path = pathandfile;
- char *p = strrchr(pathandfile, '/');
- char *filename = p + 1;
- *p = '\0';
-
- Also, some systems have functions named makepath and splitpath.
-
- Later,
- AriL
-
-
- --
- All my opinions are mine and mine alone.
-